/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.clinicplus.manager;

import br.com.foxline.clinicplus.entity.Income;
import br.com.foxline.clinicplus.service.IncomeService;
import br.com.foxline.clinicplus.util.Msg;
import java.io.Serializable;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

/**
 *
 * @author roniere
 */
@ManagedBean
@ViewScoped
public class ManagerProblema implements Serializable {

    @EJB
    IncomeService incomeService;
    
    private List<Income> incomes;
    
    @PostConstruct
    private void init(){
        incomes = incomeService.problema();
    }

    public List<Income> getIncomes() {
        return incomes;
    }

    public void setIncomes(List<Income> incomes) {
        this.incomes = incomes;
    }
    
    public void remover(int pos){
        try{
            Income i = incomes.get(pos);
            incomeService.delete(i);
            Msg.messagemInfo();
        }catch(Exception e){
            e.printStackTrace();
            Msg.messagemError(e.getMessage());
        }
    }
    
}
